/**
 * 应收应付报表管理初始化  汇总
 */
var Borrowing = {
    id: "BorrowingTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
Borrowing.initColumn = function () {
return [
        [
		    {field: 'selectItem', radio: true,colspan: 1,rowspan: 2,width:'36px'},
		    {title: '单位名称', field: 'custor', visible: true, align: 'center', valign: 'middle',colspan: 1,rowspan: 2},
			{title: '上期余额', field: 'lastBalance', visible: true, align: 'center', valign: 'middle',colspan: 1,rowspan: 2},
			{title: '应收',valign:"middle",align:"center",colspan: 4,rowspan: 1},
            {title: '应付',valign:"middle",align:"center",colspan: 4,rowspan: 1},
            {title: '余额', field: 'balance', visible: true, halign:'center', align: 'right', valign: 'middle',colspan: 1,rowspan: 2},
		],
	[
	        
	        {title: 'piso', field: 'loanPISO', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: 'PISO折RMB', field: 'loanPISOtORMB', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: 'RMB', field: 'loanRMB', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: '小计', field: 'loanTotal', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: 'piso', field: 'repPISO', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: 'PISO折RMB', field: 'repPISOToRMB', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: 'RMB', field: 'repRMB', visible: true, halign:'center', align: 'right', valign: 'middle'},
            {title: '小计', field: 'repTotal', visible: true, halign:'center', align: 'right', valign: 'middle'},
	]

 ];
};

/**
 * 检查是否选中
 */
Borrowing.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        Borrowing.seItem = selected[0];
        return true;
    }
};

Borrowing.checkPayTime = function(){
    var beginDate =  $("#beginDate").val();
    var endDate =  $("#endDate").val();
    debugger;
    if (beginDate==null||beginDate==""){
        Feng.info("请选择要导出的开始时间");
        return false;
    } else {
        return true;
    }
    if (endDate==null||endDate==""){
        Feng.info("请选择要导出的结束时间");
        return false;
    } else {
        return true;
    }
};



/**
 * 导出
 */
Borrowing.exportBorrowing = function () {
    if (this.checkPayTime()) {
        window.location.href = "/borrowing/load?beginDate=" + $("#beginDate").val()+"&endDate=" + $("#endDate").val();
    }


};



Borrowing.resetSearch = function () {
    $("#beginDate").val("");
    $("#endDate").val("");
	// $("#type").val("");
}


/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
Borrowing.formParams = function() {
    var queryData = {};
    queryData['beginDate'] = $("#beginDate").val();
    queryData['endDate'] = $("#endDate").val();
	queryData['platform'] = $("#platform").val();
    return queryData;
}

/**
 * 查询应收应付报表列表
 */
Borrowing.search = function () {
    var queryData = {};
    queryData['beginDate'] = $("#beginDate").val();
    queryData['endDate'] = $("#endDate").val();
	queryData['platform'] = $("#platform").val();
    Borrowing.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = Borrowing.initColumn();
    var table = new BSTable(Borrowing.id, "/borrowing/list", defaultColunms,Borrowing);
    table.setPaginationType("client");
    table.setQueryParams(Borrowing.formParams());
	table.setShowColumns(false);
	table.setShowRefresh(false);
    Borrowing.table = table.init();
	//添加表头
	$(".fixed-table-toolbar").after("<div style='text-align: center;vertical-align: middle;font-size: 22px;color: #6979d7;font-weight: bold;'> 应付/应收款项明细余额汇总表</div>");
});
